﻿package mortal.game.view.copy.uniqueBoss.view
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.interfaces.*;

    public class UniqueBossResultWin extends ResultBaseWindow
    {
        private var _resultTip:GTextFiled;
        private var _rewardItem:BaseItem;
        private static var _instance:UniqueBossResultWin;

        public function UniqueBossResultWin(param1:ILayer = null)
        {
            if (_instance != null)
            {
                throw new Error(" UniqueBossResultWin 单例 ");
            }
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._resultTip = UIFactory.gTextField("", 32, 20 + 25, 639, 25, this, GlobalStyle.textFormatHuang2.setSize(15).center());
            this._rewardItem = UICompomentPool.getUICompoment(BaseItem);
            this._rewardItem.setItemStyle(72, ImagesConst.ShopItemBg, 0, 0);
            this._rewardItem.x = 285 + 43 - 14;
            this._rewardItem.y = 103 - 6;
            this.contentTopOf3DSprite.addChild(this._rewardItem);
            this._rewardItem.itemCode = int(CopyConfig.instance.getCopyInfoByCode(GameConst.UniqueBossCopyCode).rewardShow);
            setContentBgSize(370, 96 + 20);
            this.updateInfo();
            _enterBtn.y = 13;
            return;
        }// end function

        override protected function enterBtnClickHandler(event:MouseEvent) : void
        {
            super.enterBtnClickHandler(event);
            GameProxy.copy.leaveCopy();
            return;
        }// end function

        private function updateInfo() : void
        {
            var _loc_2:TBoss = null;
            var _loc_3:String = null;
            var _loc_1:* = Cache.instance.copy.uniqueBoss.sUniqueBossResMsg;
            if (_loc_1)
            {
                resultType = _loc_1.result ? (ResultBaseWindow.showSuccess) : (ResultBaseWindow.showFail);
                _loc_2 = BossConfig.instance.getInfoByCode(GameConst.UniqueBossCode);
                _loc_3 = _loc_2 ? (_loc_2.name) : (Language.getString(40963));
                if (_loc_1.result)
                {
                    this._resultTip.text = Language.getString(40964) + _loc_3;
                }
                else
                {
                    this._resultTip.text = Language.getString(40965) + _loc_3;
                }
            }
            return;
        }// end function

        override protected function updateSize() : void
        {
            super.updateSize();
            if (_typeBg)
            {
                _typeBg.x = (this.width - 454) * 0.5 - 15;
                _typeBg.y = 35;
            }
            if (_contentBg)
            {
                _contentBg.x = (this.width - _contentBg.width) * 0.5;
                _contentBg.y = _typeBg.y + 42 - 7;
            }
            if (_enterBtn)
            {
                _enterBtn.x = (this.width - _enterBtn.width) * 0.5;
                _enterBtn.y = this.height - _enterBtn.height - 84 - 20;
            }
            if (_resultIcon)
            {
                _resultIcon.x = (this.width - 251) * 0.5 + 7;
                _resultIcon.y = -40;
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._resultTip.dispose();
            this._resultTip = null;
            this._rewardItem.dispose();
            this._rewardItem = null;
            return;
        }// end function

        public static function get instance() : UniqueBossResultWin
        {
            if (_instance == null)
            {
                _instance = new UniqueBossResultWin;
            }
            return _instance;
        }// end function

        public static function get isViewShow() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
